package datasource;

import com.zaxxer.hikari.HikariDataSource;
import entity.DataSourceProperty;
import javax.sql.DataSource;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

/**
 * sass数据源
 */

public class DynamicDataSource extends AbstractRoutingDataSource {

    private DataSourceCreator dataSourceCreator;

    public DynamicDataSource(DataSourceCreator dataSourceCreator) {
        this.dataSourceCreator = dataSourceCreator;
    }

    @Override
    //决定走哪个数据源
    protected Object determineCurrentLookupKey() {
        return null;
    }

    @Override
    public void afterPropertiesSet() {
        //从数据库中获取数据源
        DataSource dataSource = dataSourceCreator.createDataSource(HikariDataSource.class, new DataSourceProperty());
        //解析数据源

    }

    //增加数据源
    void addDateSource(DataSource dataSource){

    }


    //移除数据源
}
